package com.example.controller;

import com.alibaba.fastjson.JSON;
import com.example.domain.ExportTask;
import com.example.domain.Task;
import com.example.service.ExportTaskServiceImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
//@Slf4j
public class JsonHandlerController {
    private static final Logger log = LoggerFactory.getLogger(JsonHandlerController.class);


    @Autowired
    private ExportTaskServiceImpl exportTaskService;


    /***
     * 通过PlatformTransactionManager实现编程式事务（不推荐）
     */
    @RequestMapping(value = "/test/jsonHandler")
    void jsonHandler() {
        log.info("执行方法");
        ExportTask ter = new ExportTask();
        ter.setTaskName("333");
        Task task = new Task();
        task.setName("12121");
        ter.setTaskParams(task);
        exportTaskService.save(ter);
        ExportTask byId = exportTaskService.getById(ter.getId());
        log.info("执行方法byId:{}", JSON.toJSONString(byId));

    }


}
